package com.by;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/12 15:15
 * @注释
 */
// 具体原型类
public class Document implements Prototype<Document>,Cloneable{
    private String title;   // 文档标题
    private String content; // 文档内容
    private String author;  // 文档作者

    // 构造函数
    public Document(String title, String content, String author) {
        this.title = title;
        this.content = content;
        this.author = author;
    }

    // Getter 和 Setter 方法
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    // 实现克隆方法
    @Override
    public Document clone() {
        // 使用浅拷贝创建新对象
        try {
            return (Document) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException("Clone not supported", e);
        }
    }

    // 显示文档信息
    public void display() {
        System.out.println("Title: " + title);
        System.out.println("Content: " + content);
        System.out.println("Author: " + author);
    }
}
